package com.job.structureType.combination;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 王博
 * @DateTime 2025-06-17 08:39
 */
public class Menu extends MenuComponent{
    private List<MenuComponent> menuComponents = new ArrayList<MenuComponent>();
    Menu(String name, Integer level) {
        super(name, level);
    }

    @Override
    public void addComponent(MenuComponent component) {
        menuComponents.add(component);
    }

    @Override
    public void removeComponent(MenuComponent component) {
        menuComponents.remove(component);
    }

    @Override
    public void print() {
        for (int i = 0; i < getLevel(); i++) {
            System.out.print("-");
        }
        System.out.println(getName());
        for (MenuComponent menuComponent : menuComponents) {
            menuComponent.print();
        }
    }
}
